﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Wall : MonoBehaviour {

	// 对象被激活调用
	void Awake(){	
	}
	// 对象被激活，且该脚本允许才被调用
	void OnEnable(){	
	}
	public void UpdateModel(bool isEditor = false)
	{
		int x = (int)(gameObject.transform.position.x);
		int y = (int)(gameObject.transform.position.z);
		if(x == 0 && y == 0)
		{
			return;
		}
		if(!isEditor && !GridManager.GetInstance().CanAddObj(ObjType.eot_Wall, 1, 1, x, y))
		{
			Destroy(this);
		}
		else
		{
			GridManager.GetInstance().AddBuilding(ObjType.eot_Wall, "rotate82wall", x, y);
		}
	}
	// Use this for initialization
	void Start () {	
		UpdateModel();
	}
	void OnDestroy () {
		int x = (int)(gameObject.transform.position.x);
		int y = (int)(gameObject.transform.position.z);
		if(x == 0 && y == 0)
		{
			return;
		}
		GridManager.GetInstance().DelBuilding(x, y);
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}
